import 'package:base_flutter/base_flutter.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:ls_work/res/colors.dart';
import 'package:ls_work/util/log_utils.dart';

import '../../ui/bed/bed_record_fragment.dart';
import '../../ui/bed/current_bed_info_fragment.dart';

class BedChangeHistoryPage extends BaseStatefulMvvmWidget {
  final String bedId;

  BedChangeHistoryPage(this.bedId);

  @override
  State<StatefulWidget> createState() => _BedChangeHistoryState();
}

class _BedChangeHistoryState
    extends BaseMvvmState<CommonViewModel, BedChangeHistoryPage> {
  @override
  Widget buildLoadingContentView() {
    return DefaultTabController(
        length: 2,
        child: Column(
          children: [
            Material(
              color: Colors.white,
              child: TabBar(
                indicatorColor: Colours.app_main,
                labelColor: Colours.app_main,
                unselectedLabelColor: Colors.black,
                indicatorSize: TabBarIndicatorSize.label,
                tabs: [
                  Tab(
                    text: '当前床位信息',
                  ),
                  Tab(
                    text: '历史入住记录',
                  ),
                ],
              ),
            ),

            TabBarView(children: [
              CurrentBedInfoFragment(widget.bedId),
              BedRecordFragment(widget.bedId)
            ]).setWeight(1)
          ],
        ));
  }

  @override
  Widget buildRootView(BuildContext context, Widget loadingContentWidget) {
    return Scaffold(
      backgroundColor: Color(0xfff2f2f2),
      appBar: AppBar(
        title: Text('床位信息'),
        centerTitle: true,
      ),
      body: loadingContentWidget,
    );
  }

  @override
  CommonViewModel createViewModel() {
    return CommonViewModel(context);
  }

  @override
  void onRetryClick() {}
}
